package com.rw;

import com.rw.pojo.OtherTeacher;
import com.rw.pojo.Student;
import com.rw.pojo.Teacher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {
    public static void main(String[] args) {
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationcontext.xml");
        Student stu = (Student) ac.getBean("stu");
        System.out.println(stu);
        //使用ioc的DI以后，那么可以省略一下两行代码。
        stu.getTea().speak("我是超人");
        Student stu1 = (Student) ac.getBean("stu1");
        stu1.getTea().speak("我是超人2");
        OtherTeacher ot = (OtherTeacher) ac.getBean("oTea");
        System.out.println("teacher的实例="+ot);
    }
}
